package com.credit.jumu.playcard.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.credit.jumu.playcard.R;
import com.credit.jumu.playcard.base.BaseActivity;
import com.credit.jumu.playcard.bean.HomeInfo;
import com.credit.jumu.playcard.utils.ToastUtil;
import com.credit.jumu.playcard.view.ChooseCardDialog;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/10/20/020.
 */
//支付金额
public class RepaymentSetActivity extends BaseActivity implements ChooseCardDialog.OnItemClickListener {
	TextView repaysetchoose;
	ImageView imageIcon;
	ImageView titleback;
	TextView title, paycardtitle, choosecardname;
	RelativeLayout choosepayway, payrepayment;
	ChooseCardDialog chooseCardDialog;
	private List<HomeInfo> mlistInfo = new ArrayList<HomeInfo>();
	private boolean isToPay = false;

	@Override
	protected void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_repaymentset);
		imageIcon = (ImageView) findViewById(R.id.imageIcon);
		imageIcon.setVisibility(View.GONE);
		titleback = (ImageView) findViewById(R.id.titleback);
		titleback.setVisibility(View.VISIBLE);
		title = (TextView) findViewById(R.id.title);
		paycardtitle = (TextView) findViewById(R.id.paycardtitle);
		title.setText("支付金额");
		choosepayway = (RelativeLayout) findViewById(R.id.choosepayway);
		payrepayment = (RelativeLayout) findViewById(R.id.payrepayment);
		repaysetchoose = (TextView) findViewById(R.id.repaysetchoose);
		choosecardname = (TextView) findViewById(R.id.choosecardname);
		backClick(R.id.titleback, this);
		choosepayway.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				setInfo();
				if (null == chooseCardDialog) {
					chooseCardDialog = new ChooseCardDialog(RepaymentSetActivity.this, mlistInfo, RepaymentSetActivity.this);
				}
				chooseCardDialog.showDialog();
			}
		});
		repaysetchoose.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				ToastUtil.showShortToast("功能尚未开通");
				RepaymentSetActivity.this.finish();
			}
		});
	}

	public void setInfo() {
		mlistInfo.clear();
		int i = 0;
		while (i < 6) {
			HomeInfo information = new HomeInfo();
			information.setId(1000 + i);
			information.setTitle("招商银行 储蓄卡  (3514********985)");
			information.setDetails("详细信息" + i);
			information.setAvatar(R.mipmap.tab1_normal);

			mlistInfo.add(information); //将新的info对象加入到信息列表中
			i++;
		}
	}

	@Override
	public void onItemClick(int position) {
		ToastUtil.showShortToast("点击的银行卡是" + position);
		choosecardname.setText(mlistInfo.get(position).getTitle());
		chooseCardDialog.cancelDialog();
	}
}
